<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
	</head>

	<body>
		<form class="layui-form fenzu_form" action="" method="post">
			<input type="text" id="id" name="id" value="{$list.id}" style="display: none;">
			<div class="layui-form-item">
				<label class="layui-form-label">草根</label>
				<div class="layui-input-block">
					<input type="text" id="number1" name="number1" value="{$list.number1}" autocomplete="off" class="layui-input" required lay-verify="required">
					<i></i>
					<input id="lay_1" class="layui-input special" type="text" readonly="readonly" placeholder="{$list.number2}元" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">平民</label>
				<div class="layui-input-block">
					<input data-value="1" id="number2" type="text" name="number2" value="{$list.number2}" autocomplete="off" class="layui-input" required lay-verify="required">
					<i></i>
					<input id="lay_2" class="layui-input special" type="text" readonly="readonly" placeholder="{$list.number3}元" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">小资</label>
				<div class="layui-input-block">
					<input data-value="2" id="number3" name="number3" type="text" name="title" required lay-verify="required" value="{$list.number3}" autocomplete="off" class="layui-input">
					<i></i>
					<input id="lay_3" class="layui-input special" type="text" readonly="readonly" placeholder="{$list.number4}元" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">土豪</label>
				<div class="layui-input-block">
					<input data-value="3" id="number4" name="number4" type="text" value="{$list.number4}" class="layui-input" autocomplete="off" class="layui-input" required lay-verify="required">
					<i></i>
					<input id="lay_4" class="layui-input special" type="text" readonly="readonly" placeholder="{$list.number5}元" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">老客户</label>
				<div class="layui-input-block">
					<input data-value="4" id="number5" type="text" name="number5" required lay-verify="required" value="{$list.number5}" autocomplete="off" class="layui-input">
					<input class="layui-input special" type="text" readonly="readonly" placeholder="元以上" />
				</div>
			</div>
			<div class="layui-form-item huiyuan_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn" type="button" id="tijiao" lay-submit lay-filter="submit_from">保存</button>
				</div>
			</div>
		</form>
		<script>
			layui.use('form', function() {
				var form = layui.form;
				//监听表单提交
				form.on('submit(submit_from)', function(data){
					tijiao();
		  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
				});
			});
		</script>
	</body>

</html>
<script>
	$(".layui-input-block input[type='text']").change(function() {
		var value = $(this).data("value");
		if(value) {
			$("#lay_" + value).val($(this).val() + "元");
		}

	})

	function tijiao() {
		$.ajax({
			type: 'POST',
			data: {
				id: $('#id').val(),
				number1: $("#number1").val(),
				number2: $("#number2").val(),
				number3: $("#number3").val(),
				number4: $("#number4").val(),
				number5: $("#number5").val()
			},
			url: "{:url('accounts/fenzu_setting2')}",
			success: function(data) {
				if(data.code == 200) {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					}, function() {
						window.parent.location.reload();
					});
				} else {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
				}

			}
		});
	}
</script>